package com.qdu.util;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentPBEConfig;

public class EncryptUtil {

    private EncryptUtil(){}
    private static final String PASSWORD = "12345";
    private static final StandardPBEStringEncryptor encryptor;

    /*这里可能是盐*/
    static {
        encryptor = new StandardPBEStringEncryptor();
        EnvironmentPBEConfig config = new EnvironmentPBEConfig();
        config.setAlgorithm("PBEWithMD5AndDES");
        encryptor.setPassword(PASSWORD);
    }

    /*加密*/
    public static String encrypt(String text){
        return encryptor.encrypt(text);
    }

    /**
     *
     * ciphertext密文
     * 解密
     * */
    public static String decrypt(String ciphertext){
        return encryptor.decrypt(ciphertext);
    }

}
